package com.zjlanyun.erp;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class WarningDetail extends Activity {
	
	private TextView title;
	private LinearLayout ll_back;
	private Context mContext = this;
	private LinearLayout mainContent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.warning_detail);
		initView();
		initData();
	}

	//初始化View
	private void initView(){
		title = (TextView) findViewById(R.id.title);
		ll_back = (LinearLayout) findViewById(R.id.ll_back);
		mainContent = (LinearLayout) findViewById(R.id.content);
		
		Intent intent = getIntent();
		
		title.setText(intent.getStringExtra("billtype")+"详情");
		
		//后退
		ll_back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
	}
	
	//初始化数据
	private void initData(){
		String[] titles = {"采购订单信息","供应商信息","业务员信息"};
		ArrayList<ArrayList<HashMap<String, String>>> list = new ArrayList<ArrayList<HashMap<String, String>>>();
		
		String[] keys = {"单据编号","单据日期","到货日期","采购订金","单据金额","仓库名称","制单人"};
		String[] values = {"PO-2014-07-0002","2014-07-16","2014-07-28","1,000.00","1,494.00","零食仓","wulic"};
		ArrayList<HashMap<String, String>> mList = new ArrayList<HashMap<String, String>>();
		for(int i = 0; i < keys.length; i++){
			HashMap<String, String> map = new HashMap<String, String>();
			map.put("key", keys[i]);
			map.put("value", values[i]);
			mList.add(map);
		}
		list.add(mList);
		
		keys = new String[] {"供应商编号","供应商名称","联系人","电话"};
		values = new String[] {"wl002","上海良品铺子电子商务有限公司","李敏","13600557651"};
		mList = new ArrayList<HashMap<String, String>>();
		for(int i = 0; i < keys.length; i++){
			HashMap<String, String> map = new HashMap<String, String>();
			map.put("key", keys[i]);
			map.put("value", values[i]);
			mList.add(map);
		}
		list.add(mList);
		
		keys = new String[] {"业务员","电话"};
		values = new String[] {"王立宇","13600557651"};
		mList = new ArrayList<HashMap<String, String>>();
		for(int i = 0; i < keys.length; i++){
			HashMap<String, String> map = new HashMap<String, String>();
			map.put("key", keys[i]);
			map.put("value", values[i]);
			mList.add(map);
		}
		list.add(mList);
		
		
		for(int i = 0; i < titles.length; i++){
			LayoutInflater layoutInflater = LayoutInflater.from(mContext);
			View view = layoutInflater.inflate(R.layout.warning_detail_item, null);
			
			TextView title = (TextView) view.findViewById(R.id.title);
			title.setText(titles[i]);
			LinearLayout content = (LinearLayout) view.findViewById(R.id.content);
			
			mList = new ArrayList<HashMap<String, String>>();
			mList = list.get(i);
			
			for(int j = 0; j < mList.size(); j++){
				LayoutInflater layoutInflater2 = LayoutInflater.from(mContext);
				View view2 = layoutInflater2.inflate(R.layout.warning_detail_item_item, null);
				TextView key = (TextView) view2.findViewById(R.id.key);
				TextView value = (TextView) view2.findViewById(R.id.value);
				key.setText(mList.get(j).get("key")+" : ");
				value.setText(mList.get(j).get("value"));
				content.addView(view2);
			}
			mainContent.addView(view);
		}
		
	}
}
